function toLine(name) {
  return name.replace(/([A-Z])/g,"_$1").toLowerCase();
}

function toHump(name) {
  return name.replace(/\_(\w)/g, function(all, letter){
      return letter.toUpperCase();
  });
}

function formatResponse(obj) {
  if(obj === null || obj === undefined || typeof obj !== 'object') return;
  if(Array.isArray(obj)) {
    obj.forEach(item => formatResponse(item));
  } else {
    Object.keys(obj).forEach(key => {
      let humpKey = toHump(key);
      let lineKey = toLine(key);
      obj[humpKey] = obj[key];
      obj[lineKey] = obj[key];
      formatResponse(obj[key]);
    })
  }
}

export {
  toHump,
  toLine,
  formatResponse
}